/*
Hermes Core: General Purpose Mobile Agent Platform
Copyright (C) 2006 UNICAM - Università degli Studi di Camerino

Group leaders: Flavio Corradini and Emanuela Merelli

Developers: Ezio Bartocci, Diego Bonura, Rosario Culmone,
Davide Lorenzoli, Leonardo Mariani, Francesca Piersigilli, 
Lorenzo Scortichini, Leonardo Vito.

GNU Lesser Public License

This library is free software; you can redistribute it 
and/or modify it under the terms of the GNU Lesser General 
Public License as published by the Free Software Foundation, 
version 2.1 of the License.

This library is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public 
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.

Emanuela Merelli
Dipartimento di Matematica ed Informatica
Università di Camerino
via Madonna delle Carceri, 62032 Camerino, Italy
E.Mail: emanuela.merelli@unicam.it
*/
package hermesV2.util.loggers;

import hermesV2.util.HermesLogger;
import hermesV2.util.HermesLoggerDriver;

/**
 * This is the class that rappresents the console logger for the hermes
 * plattform
 */
public class HermesSimpleLogger implements HermesLoggerDriver {
    /**
     * Creates a new HermesConsoleLogger object.
     * 
     * @param propertyFileName
     *            The property file of the logger
     */
    public HermesSimpleLogger(String propertyFileName) {
        HermesLogger.setLogger(this);
    }

    /**
     * Logs a message into the handler. It uses the trace stack to know which
     * class plus method called the log.
     * 
     * @param level
     *            The level of the message to log.
     * @param message
     *            the message to log.
     */
    public void log(int level, String message) {
        switch (level) {
        case HermesLogger.INFO:
            System.out.println("Level INFO  message: " + message);
            break;

        case HermesLogger.WARNING:
            System.out.println("Level WARNING message: " + message);
            break;

        case HermesLogger.DEBUG:
            System.out.println("Level DEBUG  message: " + message);
            break;

        case HermesLogger.ERROR:
            System.out.println("Level ERROR message: " + message);
            break;

        case HermesLogger.FATAL:
            System.out.println("Level FATAL message: " + message);
            break;
        }
    }

    /**
     * Logs a message into the handler. It uses the trace stack to know which
     * class plus method called the log.
     * 
     * @param level
     *            The level of the message to log.
     * @param message
     *            the message to log.
     * @param e
     *            The exception to log.
     */
    public void log(int level, String message, Exception e) {
        switch (level) {
        case HermesLogger.INFO:
            System.out.println("Level INFO  message: " + message+ " Exception: " + e);
            break;

        case HermesLogger.WARNING:
            System.out.println("Level WARNING message: " + message+ " Exception: " + e);
            break;

        case HermesLogger.DEBUG:
            System.out.println("Level DEBUG  message: " + message+ " Exception: " + e);
            break;

        case HermesLogger.ERROR:
            System.out.println("Level ERROR message: " + message+ " Exception: " + e);
            break;

        case HermesLogger.FATAL:
            System.out.println("Level FATAL message: " + message+ " Exception: " + e);
            break;
        }
    }
}